{extend name="common/base" /}
{block name="title"}添加商品分类{/block}
{block name="main"}
<script src="/ad/js/g_add/g_type.js"></script>
     <!-- Navigation -->
	   <div id="page-wrapper">
        <div class="col-md-12 graphs">
		<div class="xs">
  	    <h3>添加商品分类</h3>
  	    <div class="well1 white">
        <form class="form-floating" id="g_type" novalidate="novalidate" ng-submit="submit()" action="{:url('Goods/dog_type')}" method ='post' enctype="multipart/form-data">
          <fieldset>
            <div class="form-group">
              <label class="control-label">分类名称</label>
              <input name="goods_type_name" type="text" class="form-control1 goods_type_name" value="{$res['goods_type_name']?$res['goods_type_name']:''}" required="">
              <input type="hidden" name="goods_type_id" value="{$res['goods_type_id']?$res['goods_type_id']:''}">
            </div>
            <div class="form-group filled">
                <label class="control-label">分类类型</label>
                <select class="form-control1 type" name="goods_type_pid">
              <option value="0">主分类</option>
              {volist name="g_type" id="gty"}
                <option value="{$gty['goods_type_id']}" {$res['goods_a_type']?($res['goods_a_type'] == $gty["goods_type_id"]?"selected":""):""}>{$gty.goods_type_name}</option>
            {/volist}
              </select>
            </div>
              <div class="form-group">
                  <label class="control-label">分类排序</label>
                  <input name="goods_type_sort" type="text" class="form-control1 goods_type_sort" value="{$res['goods_type_sort']?$res['goods_type_sort']:''}" required="">
              </div>
              <div class="zhu">
                  <div class="form-group ">
                      <label class="control-label">分类分组</label>
                      <input name="goods_group" type="text" class="form-control1 goods_type_name" value="{$res['goods_group']?$res['goods_group']:''}" required="">
                  </div>
                  <div class="form-group">
                      <label class="control-label">分类图标</label>
                      <input  type="file" ng-model="model.file" required="" id="exampleInputFile">
                      <!-- 显示图片的地方 -->
                      <div id="destination" style="margin-top:10px;">
                          <input type="hidden" name="goods_type_icon" value="{$res['goods_type_icon']?$res['goods_type_icon']:''}">
                          <img src="{$res['goods_type_icon']?$res['goods_type_icon']:''}" style="width:100px;"></div>

                  </div>
              </div>
            <div class="form-group">
              <button type="button" class="btn btn-primary">提交</button>
              <button type="reset" class="btn btn-default">重置</button>
            </div>
          </fieldset>
        </form>
      </div>
    </div>
            <script type="text/javascript">
                document.getElementById('exampleInputFile').addEventListener('change', function() {
                    var file;
                    var destination = document.getElementById('destination');
                    destination.innerHTML = '';

                    // 循环用户多选的文件
                    for(var x = 0, xlen = this.files.length; x < xlen; x++) {
                        file = this.files[x];
                        if(file.type.indexOf('image') != -1) { // 非常简单的交验

                            var reader = new FileReader();

                            reader.onload = function(e) {
                                var img = new Image();
                                var input = document.createElement("input");
                                input.type = 'hidden';
                                input.value = e.target.result;
                                input.name = 'goods_type_icon';
                                img.src = e.target.result; // 显示图片的地方
                                img.width = 100;
                                destination.appendChild(img);
                                destination.appendChild(input);
                            };

                            reader.readAsDataURL(file);
                        }
                    }
                });
                //隐藏提示消息
                /*window.onload = function(){
                 setInterval(function(){
                 $("#jg").fadeOut(1000);
                 }, 3000);
                 }*/
            </script>
		{/block}



